package com.diyunapp.xilinapp.myindent;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.diyunapp.xilinapp.R;
import com.diyunapp.xilinapp.main.MainActivity;
import com.diyunapp.xilinapp.selfdefine.StatusBarFragmentActivity;
import com.diyunapp.xilinapp.utils.UploadUtils;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import com.yuyh.library.imgsel.ImageLoader;
import com.yuyh.library.imgsel.ImgSelActivity;
import com.yuyh.library.imgsel.ImgSelConfig;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class TradeComplaintsaActivity extends StatusBarFragmentActivity implements UploadUtils.OnUploadProcessListener {

    @Bind(R.id.go_back)
    ImageView goBack;
    @Bind(R.id.Spinner01)
    Spinner Spinner01;
    @Bind(R.id.refund_state_edt)
    EditText refundStateEdt;
    @Bind(R.id.pz_1)
    ImageView pz1;
    @Bind(R.id.pz_2)
    ImageView pz2;
    @Bind(R.id.pz_3)
    ImageView pz3;
    @Bind(R.id.sure_to_apply)
    TextView sureToApply;
    private int REQUEST_CODE = 1;

    private String src1=null;
    private String src2=null;
    private String src3=null;
    private List<String> pathList=null;
    private int pzState=0;
    private static final String[] state = {"售后保障服务", "未收到货"};
    public String gd_id;
    public String order_id;

    private static final long PICSIZELIMIT = 480000;
    private String myPhotoPath;
    private String myPhotoPath2;
    private String myPhotoPath3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_trade_complaintsa);
        ButterKnife.bind(this);
        View headView;
        headView = findViewById(R.id.complains_menubar_inc);
        super.MenuWidget(headView);
        gd_id = getIntent().getExtras().getString("gd_id");
        order_id = getIntent().getExtras().getString("order_id");
        dropDown();
    }

    @OnClick({R.id.go_back, R.id.pz_1, R.id.sure_to_apply})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.go_back:
                finish();
                break;
            case R.id.pz_1:
                //shangchuan
                ImgSelActivity.startActivity(this, config, REQUEST_CODE);
                break;
            case R.id.sure_to_apply:
                //tijiao
                commit(src1,src2,src3);
                break;
        }
    }

    public void dropDown() {


        SpinnerAdapter adapter = new SpinnerAdapter(this,
                android.R.layout.simple_spinner_item, state);

            Spinner01.setAdapter(adapter);

        //将可选内容与ArrayAdapter连接起来
//        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, state);
//        //设置下拉列表的风格
//        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//        //将adapter 添加到spinner中
//        Spinner01.setAdapter(adapter);
        //添加事件Spinner事件监听
//        Spinner01.setOnItemSelectedListener(new SpinnerSelectedListener());
        //设置默认值
        Spinner01.setVisibility(View.VISIBLE);

    }
    public Bitmap compScale(String srcPath) throws Exception {

        int degree = getPicRotate(srcPath);
        Log.i("zhangxiaoxidebug", "resultinfo11111111="+degree);
        BitmapFactory.Options options = new  BitmapFactory.Options();
        Log.i("zhangxiaoxidebug", "resultinfo2222222222=");
        options.inJustDecodeBounds =  false;
        Log.i("zhangxiaoxidebug", "resultinfo33333333333=");
        options.inSampleSize = 4;
        Log.i("zhangxiaoxidebug", "resultinfo4444444444=");
        Bitmap bitmap = BitmapFactory.decodeFile(srcPath, options);
        Log.i("zhangxiaoxidebug", "resultinfo555555=");
        if(degree!=0)
        {
            Matrix m = new Matrix();
            int width = bitmap.getWidth();
            int height = bitmap.getHeight();
            m.setRotate(degree); // 旋转angle度
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height,m, true);// 从新生成图片
        }
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        long picbytes = width*height;
        String Picname = MainActivity.myLogin.getLoginkey();
        if(Picname.isEmpty())
        {
            Picname = "12345678912";
        }
        myPhotoPath = srcPath.substring(0,srcPath.lastIndexOf("/")+1) + Picname+"pingzheng.jpg";
        FileOutputStream fops = new FileOutputStream(myPhotoPath);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        Log.e("LogUtil", "baos当前图片压缩为：" + baos.toByteArray().length / 1024 + "kb");
        if(picbytes>PICSIZELIMIT)
        {
            BitmapFactory.Options newOpts = new BitmapFactory.Options();
            // 开始读入图片，此时把options.inJustDecodeBounds 设回true了
            newOpts.inJustDecodeBounds = true;
            Bitmap map = BitmapFactory.decodeByteArray(baos.toByteArray(), 0, baos.toByteArray().length, newOpts);
            // 重新读入图片，注意此时已经把options.inJustDecodeBounds 设回false了
            newOpts.inJustDecodeBounds = false;
            int w = newOpts.outWidth;
            int h = newOpts.outHeight;
            Log.e("LogUtil", "outWidth:" + w + "----------" + "outHeight:" + h);
            // 现在主流手机比较多是800*480分辨率，所以高和宽我们设置为
            float ww = 1280f;// 这里设置宽度为600f
            float hh = 720f;// 这里设置高度为800f
            // 缩放比。由于是固定比例缩放，只用高或者宽其中一个数据进行计算即可
            int be = 1;// be=1表示不缩放
            if (w > h && w > ww) {// 如果宽度大的话根据宽度固定大小缩放
                be = (int) (newOpts.outWidth / ww);
            } else if (w < h && h > hh) {// 如果高度高的话根据宽度固定大小缩放
                be = (int) (newOpts.outHeight / hh);
            }
            if (be <= 0)
                be = 1;
            Log.e("LogUtil", "be:" + be);
            newOpts.inSampleSize = be;// 设置缩放比例
            map = BitmapFactory.decodeByteArray(baos.toByteArray(), 0, baos.toByteArray().length, newOpts);
            ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
            map.compress(Bitmap.CompressFormat.JPEG, 100, baos1);
            Log.e("LogUtil", "baos1当前图片压缩为：" + baos1.toByteArray().length / 1024 + "kb");
            fops.write(baos1.toByteArray());
            fops.flush();
            fops.close();
            return map;
        }
        else
        {
            fops.write(baos.toByteArray());
            fops.flush();
            fops.close();
            return bitmap;
        }
    }
    public Bitmap compScale2(String srcPath) throws Exception {

        int degree = getPicRotate(srcPath);
        Log.i("zhangxiaoxidebug", "resultinfo11111111="+degree);
        BitmapFactory.Options options = new  BitmapFactory.Options();
        Log.i("zhangxiaoxidebug", "resultinfo2222222222=");
        options.inJustDecodeBounds =  false;
        Log.i("zhangxiaoxidebug", "resultinfo33333333333=");
        options.inSampleSize = 4;
        Log.i("zhangxiaoxidebug", "resultinfo4444444444=");
        Bitmap bitmap = BitmapFactory.decodeFile(srcPath, options);
        Log.i("zhangxiaoxidebug", "resultinfo555555=");
        if(degree!=0)
        {
            Matrix m = new Matrix();
            int width = bitmap.getWidth();
            int height = bitmap.getHeight();
            m.setRotate(degree); // 旋转angle度
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height,m, true);// 从新生成图片
        }
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        long picbytes = width*height;
        String Picname = MainActivity.myLogin.getLoginkey();
        if(Picname.isEmpty())
        {
            Picname = "12345678912";
        }
        myPhotoPath2 = srcPath.substring(0,srcPath.lastIndexOf("/")+1) + Picname+"pingzheng1.jpg";
        FileOutputStream fops = new FileOutputStream(myPhotoPath2);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        Log.e("LogUtil", "baos当前图片压缩为：" + baos.toByteArray().length / 1024 + "kb");
        if(picbytes>PICSIZELIMIT)
        {
            BitmapFactory.Options newOpts = new BitmapFactory.Options();
            // 开始读入图片，此时把options.inJustDecodeBounds 设回true了
            newOpts.inJustDecodeBounds = true;
            Bitmap map = BitmapFactory.decodeByteArray(baos.toByteArray(), 0, baos.toByteArray().length, newOpts);
            // 重新读入图片，注意此时已经把options.inJustDecodeBounds 设回false了
            newOpts.inJustDecodeBounds = false;
            int w = newOpts.outWidth;
            int h = newOpts.outHeight;
            Log.e("LogUtil", "outWidth:" + w + "----------" + "outHeight:" + h);
            // 现在主流手机比较多是800*480分辨率，所以高和宽我们设置为
            float ww = 1280f;// 这里设置宽度为600f
            float hh = 720f;// 这里设置高度为800f
            // 缩放比。由于是固定比例缩放，只用高或者宽其中一个数据进行计算即可
            int be = 1;// be=1表示不缩放
            if (w > h && w > ww) {// 如果宽度大的话根据宽度固定大小缩放
                be = (int) (newOpts.outWidth / ww);
            } else if (w < h && h > hh) {// 如果高度高的话根据宽度固定大小缩放
                be = (int) (newOpts.outHeight / hh);
            }
            if (be <= 0)
                be = 1;
            Log.e("LogUtil", "be:" + be);
            newOpts.inSampleSize = be;// 设置缩放比例
            map = BitmapFactory.decodeByteArray(baos.toByteArray(), 0, baos.toByteArray().length, newOpts);
            ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
            map.compress(Bitmap.CompressFormat.JPEG, 100, baos1);
            Log.e("LogUtil", "baos1当前图片压缩为：" + baos1.toByteArray().length / 1024 + "kb");
            fops.write(baos1.toByteArray());
            fops.flush();
            fops.close();
            return map;
        }
        else
        {
            fops.write(baos.toByteArray());
            fops.flush();
            fops.close();
            return bitmap;
        }
    }
    public Bitmap compScale3(String srcPath) throws Exception {

        int degree = getPicRotate(srcPath);
        Log.i("zhangxiaoxidebug", "resultinfo11111111="+degree);
        BitmapFactory.Options options = new  BitmapFactory.Options();
        Log.i("zhangxiaoxidebug", "resultinfo2222222222=");
        options.inJustDecodeBounds =  false;
        Log.i("zhangxiaoxidebug", "resultinfo33333333333=");
        options.inSampleSize = 4;
        Log.i("zhangxiaoxidebug", "resultinfo4444444444=");
        Bitmap bitmap = BitmapFactory.decodeFile(srcPath, options);
        Log.i("zhangxiaoxidebug", "resultinfo555555=");
        if(degree!=0)
        {
            Matrix m = new Matrix();
            int width = bitmap.getWidth();
            int height = bitmap.getHeight();
            m.setRotate(degree); // 旋转angle度
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height,m, true);// 从新生成图片
        }
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        long picbytes = width*height;
        String Picname = MainActivity.myLogin.getLoginkey();
        if(Picname.isEmpty())
        {
            Picname = "12345678912";
        }
        myPhotoPath3 = srcPath.substring(0,srcPath.lastIndexOf("/")+1) + Picname+"pingzheng1.jpg";
        FileOutputStream fops = new FileOutputStream(myPhotoPath3);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        Log.e("LogUtil", "baos当前图片压缩为：" + baos.toByteArray().length / 1024 + "kb");
        if(picbytes>PICSIZELIMIT)
        {
            BitmapFactory.Options newOpts = new BitmapFactory.Options();
            // 开始读入图片，此时把options.inJustDecodeBounds 设回true了
            newOpts.inJustDecodeBounds = true;
            Bitmap map = BitmapFactory.decodeByteArray(baos.toByteArray(), 0, baos.toByteArray().length, newOpts);
            // 重新读入图片，注意此时已经把options.inJustDecodeBounds 设回false了
            newOpts.inJustDecodeBounds = false;
            int w = newOpts.outWidth;
            int h = newOpts.outHeight;
            Log.e("LogUtil", "outWidth:" + w + "----------" + "outHeight:" + h);
            // 现在主流手机比较多是800*480分辨率，所以高和宽我们设置为
            float ww = 1280f;// 这里设置宽度为600f
            float hh = 720f;// 这里设置高度为800f
            // 缩放比。由于是固定比例缩放，只用高或者宽其中一个数据进行计算即可
            int be = 1;// be=1表示不缩放
            if (w > h && w > ww) {// 如果宽度大的话根据宽度固定大小缩放
                be = (int) (newOpts.outWidth / ww);
            } else if (w < h && h > hh) {// 如果高度高的话根据宽度固定大小缩放
                be = (int) (newOpts.outHeight / hh);
            }
            if (be <= 0)
                be = 1;
            Log.e("LogUtil", "be:" + be);
            newOpts.inSampleSize = be;// 设置缩放比例
            map = BitmapFactory.decodeByteArray(baos.toByteArray(), 0, baos.toByteArray().length, newOpts);
            ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
            map.compress(Bitmap.CompressFormat.JPEG, 100, baos1);
            Log.e("LogUtil", "baos1当前图片压缩为：" + baos1.toByteArray().length / 1024 + "kb");
            fops.write(baos1.toByteArray());
            fops.flush();
            fops.close();
            return map;
        }
        else
        {
            fops.write(baos.toByteArray());
            fops.flush();
            fops.close();
            return bitmap;
        }
    }


    public static int getPicRotate(String path) {
        int degree  = 0;
        try {
            ExifInterface exifInterface = new ExifInterface(path);
            int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
            switch (orientation) {
                case ExifInterface.ORIENTATION_ROTATE_90:
                    degree = 90;
                    break;
                case ExifInterface.ORIENTATION_ROTATE_180:
                    degree = 180;
                    break;
                case ExifInterface.ORIENTATION_ROTATE_270:
                    degree = 270;
                    break;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return degree;
    }
    @Override
    public void onUploadDone(int responseCode, String message) {
        Message myMes = Message.obtain();
        myMes.arg1 = responseCode;
        myMes.obj = message;
        myPicupHandle.sendMessage(myMes);
    }

    @Override
    public void onUploadProcess(int uploadSize) {
        Message myMes = Message.obtain();
        myMes.arg1 = 10;
        myMes.arg2 = uploadSize;
        myPicupHandle.sendMessage(myMes);
    }

    @Override
    public void initUpload(int fileSize) {

    }
    private Handler myPicupHandle = new Handler() {

        public void handleMessage(Message msg) {
            switch (msg.arg1) {
                case UploadUtils.UPLOAD_SUCCESS_CODE:
                    toast("申请成功");
                    finish();
                    break;
                case UploadUtils.UPLOAD_SERVER_ERROR_CODE:
                    String error = msg.obj.toString();
                    toast(error);
                    break;
                case 10:
                    Log.i("zhangxiaoxidebug","正在上传");
                    break;
                default:
                    break;
            }
        }

        ;
    };
    private class SpinnerAdapter extends ArrayAdapter<String> {
        Context context;
        String[] items = new String[] {};

        public SpinnerAdapter(final Context context,
                              final int textViewResourceId, final String[] objects) {
            super(context, textViewResourceId, objects);
            this.items = objects;
            this.context = context;
        }

        @Override
        public View getDropDownView(int position, View convertView,
                                    ViewGroup parent) {

            if (convertView == null) {
                LayoutInflater inflater = LayoutInflater.from(context);
                convertView = inflater.inflate(
                        android.R.layout.simple_spinner_item, parent, false);
            }

            TextView tv = (TextView) convertView
                    .findViewById(android.R.id.text1);
            tv.setText(items[position]);
            tv.setGravity(Gravity.CENTER);
            tv.setPadding(16,40,16,40);
            tv.setTextColor(Color.GRAY);
            tv.setTextSize(14);
            return convertView;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                LayoutInflater inflater = LayoutInflater.from(context);
                convertView = inflater.inflate(
                        android.R.layout.simple_spinner_item, parent, false);
            }

            // android.R.id.text1 is default text view in resource of the android.
            // android.R.layout.simple_spinner_item is default layout in resources of android.

            TextView tv = (TextView) convertView
                    .findViewById(android.R.id.text1);
            tv.setText(items[position]);
            tv.setGravity(Gravity.LEFT);
            tv.setTextColor(Color.GRAY);
            tv.setTextSize(14);
            return convertView;
        }
    }
    private void commit(String path,String path1,String path2) {
        String type=Spinner01.getSelectedItem().toString().trim();
        String subject=null;
        if (type == "售后保障服务") {
            subject = "3,售后保障服务";
        } else if (type == "未收到货") {
            subject = "2,未收到货";
        }
        String content=refundStateEdt.getText().toString().trim();
        String uploadURL=MainActivity.url+"act=goods&op=complain_save";
        UploadUtils uploadUtil = UploadUtils.getInstance();
        uploadUtil.setOnUploadProcessListener(this);
        Map<String, String> params = new HashMap<String, String>();
        params.put("order_id", order_id);
        params.put("goods_id", gd_id);
        params.put("input_complain_subject", subject);
        params.put("input_complain_content", content);
        params.put("member_id", MainActivity.myLogin.getMemberid());
        if(pzState==1) {
            if(pathList.size()==3){
                uploadUtil.uploadFile( myPhotoPath,myPhotoPath2,myPhotoPath3,uploadURL,params);
            }else if (pathList.size()==2){
                uploadUtil.uploadFile( myPhotoPath,myPhotoPath2,uploadURL,params);}
            else  {
                uploadUtil.uploadFile( path,uploadURL,params);}
        }else if(pzState==0) {
            String url = MainActivity.url + "act=goods&op=complain_save&order_id=" + order_id + "&goods_id=" + gd_id + "&input_complain_subject=" + subject
                    + "&input_complain_content=" + content + "&member_id=" + MainActivity.myLogin.getMemberid();
            Log.i("zhangxiaoxidebug", "url===" + url);
            HttpUtils http = new HttpUtils();
            http.configCurrentHttpCacheExpiry(1000);
            http.send(HttpRequest.HttpMethod.POST, url,
                    new RequestCallBack<String>() {
                        @Override
                        public void onLoading(long total, long current, boolean isUploading) {
                        }

                        @Override
                        public void onSuccess(ResponseInfo<String> responseInfo) {
//                        bidFreshLv.onRefreshComplete();
                            String resultinfo = responseInfo.result;
                            Log.i("zhangxiaoxidebug", "resultinfo=" + resultinfo);
//                        Logger.e("=================================="+resultinfo);
                            try {
                                JSONObject resultObject = new JSONObject(resultinfo);
                                int result = resultObject.getInt("code");
                                if (result == 200) {
                                    String data = resultObject.optString("data");
                                    toast(data);
                                    finish();
                                } else {
                                    String data = resultObject.optString("data");
                                    toast(data);
                                }
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                toast("查询失败");
                                e.printStackTrace();
                            }
                        }

                        @Override
                        public void onFailure(HttpException error, String msg) {
                            toast("请求失败");
                        }
                    });
        }
    }

    private ImageLoader loader = new ImageLoader() {
        @Override
        public void displayImage(Context context, String path, ImageView imageView) {
            // TODO 在这边可以自定义图片加载库来加载 ImageView，例如 Glide、Picasso、ImageLoader 等
            Glide.with(context).load(path).into(imageView);
        }
    };
    // 自由配置选项
    ImgSelConfig config = new ImgSelConfig.Builder(loader)
            // 是否多选
            .multiSelect(true)
            .btnTextColor(Color.WHITE)
            // 使用沉浸式状态栏
            .statusBarColor(Color.parseColor("#eb534a"))
            // 返回图标 ResId
            .backResId(R.drawable.goback)
            // 标题
            .title("图片")
            // 标题文字颜色
            .titleColor(Color.WHITE)
            // TitleBar 背景色
            .titleBgColor(Color.parseColor("#eb534a"))
            .needCamera(true)
            // 最大选择图片数量
            .maxNum(3)
            .build();

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        // 图片选择结果回调
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) {
            pathList = data.getStringArrayListExtra(ImgSelActivity.INTENT_RESULT);
            if(pathList.size()==0){
                pzState=0;
            }else{
                pzState=1;
            }
            src1 = null;
            src2 = null;
            src3 = null;

            if (pathList.size() == 1) {
                src1 = pathList.get(0);
//                pz1.setVisibility(View.VISIBLE);
//                Bitmap bitmap = BitmapUtil.createThumbnail(src1,100, 100);
//                pz1.setImageBitmap(bitmap);
                try {
                    Bitmap img = compScale(src1);
                    pz1.setImageBitmap(img);
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }else if (pathList.size() == 2) {
                src1 = pathList.get(0);
                src2 = pathList.get(1);
//
                pz1.setVisibility(View.VISIBLE);
                pz2.setVisibility(View.VISIBLE);

//                Bitmap bitmap = BitmapUtil.createThumbnail(src1,100, 100);
//                pz1.setImageBitmap(bitmap);
//                Bitmap bitmap1 = BitmapUtil.createThumbnail(src2,  100, 100);
//                pz2.setImageBitmap(bitmap1);
                try {
                    Bitmap img = compScale(src1);
                    pz1.setImageBitmap(img);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                try {
                    Bitmap img = compScale2(src2);
                    pz2.setImageBitmap(img);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }else if (pathList.size() == 3) {
                src1 = pathList.get(0);
                src2 = pathList.get(1);
                src3 = pathList.get(2);
                pz1.setVisibility(View.VISIBLE);
                pz2.setVisibility(View.VISIBLE);
                pz3.setVisibility(View.VISIBLE);

//                Bitmap bitmap = BitmapUtil.createThumbnail(src1, 100, 100);
//                pz1.setImageBitmap(bitmap);
//
//                Bitmap bitmap1 = BitmapUtil.createThumbnail(src2,  100, 100);
//                pz2.setImageBitmap(bitmap1);
//
//                Bitmap bitmap2 = BitmapUtil.createThumbnail(src3, 100, 100);
//                pz3.setImageBitmap(bitmap2);


                try {
                    Bitmap img = compScale(src1);
                    pz1.setImageBitmap(img);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                try {
                    Bitmap img = compScale2(src2);
                    pz2.setImageBitmap(img);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                try {
                    Bitmap img = compScale3(src3);
                    pz3.setImageBitmap(img);
                } catch (Exception e) {
                    e.printStackTrace();
                }



            }
            Log.i("xiaogaladebug","1---1--"+src1);
            Log.i("xiaogaladebug","2---2--"+src2);
            Log.i("xiaogaladebug","3---3--"+src3);

        }
    }
}



